import db from './db'
import { mock } from 'mockjs'

// GET 用户列表
mock('user/list', 'get', () => {
  return {
    err: 0,
    desc: '执行成功！',
    result: db.select('gx_user')
  }
})

// POST 添加用户
mock('user/add', 'post', (payload) => {
  const { username, nickname } = JSON.parse(payload.body)
  db.add('gx_user', { username, nickname })

  return { err: 0, desc: '执行成功！' }
})
